package com.net.redis_plus.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ConditionEx {

    //枚举
    private String andOr;


    private String column;

    //枚举
    private String condition;


    private Object val;

    private boolean between;

    private boolean inlist;



    public static ConditionEx checkSelf(ConditionEx conditionEx){

        if( Conditons.getConditionType(conditionEx.getCondition()) == Conditons.LIKE ){
            String val =  (String)conditionEx.getVal();
            val += "%";
            val = "%" +val;
            conditionEx.setVal(val);

        }

        if(conditionEx.getColumn() != null){
            conditionEx.setColumn("`"+ conditionEx.getColumn() + "`");
        }
        if(conditionEx.getCondition().equals("in")){
            conditionEx.setInlist(true);
        }else {
            conditionEx.setInlist(false);
        }


        return conditionEx;
    }

}
